package com.ebupt.migu.music.media.controller;


import com.ebupt.migu.music.common.entity.ResultObject;
import com.ebupt.migu.music.common.util.ReqestParamUtil;
import com.ebupt.migu.music.media.dto.AddDto;
import com.ebupt.migu.music.media.dto.PageDto;
import com.ebupt.migu.music.media.service.MediaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.jaxb.SpringDataJaxb;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


/**
 * @author wangzhu
 * @description: TODO
 * @date 2024/4/23 15:26
 */
@Slf4j
@RestController
@RequestMapping("/media")
public class MediaController {


    @Autowired
    private MediaService service;

    @RequestMapping("/configuration")
    public ResultObject configuration() {
        return service.getConditions();
    }

    @PostMapping("/list")
    public ResultObject list(@RequestBody PageDto pageDto) {
        return service.list(pageDto);
    }

    @PostMapping("/add")
    public ResultObject add(@RequestBody AddDto addDto) {
        return service.add(addDto);
    }

    @PostMapping("/update")
    public ResultObject update(@RequestBody AddDto addDto) {
        return service.update(addDto);
    }

    @RequestMapping("/updateStatus")
    public ResultObject updateStatus(HttpServletRequest request) {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return service.updateStatus(params);
    }

    @RequestMapping("/detail")
    public ResultObject detail(HttpServletRequest request) {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return service.detail(params);
    }


    @RequestMapping("/delete")
    public ResultObject delete(HttpServletRequest request) {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return service.delete(params);
    }


    @PostMapping("/checkList")
    public ResultObject checkList(@RequestBody PageDto pageDto) {
        return service.checkList(pageDto);
    }


    @RequestMapping("/checkUpdate")
    public ResultObject checkUpdate(HttpServletRequest request) {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return service.checkUpdate(params);
    }


    @RequestMapping("/checkDetail")
    public ResultObject checkDetail(HttpServletRequest request) {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return service.checkDetail(params);
    }


    @RequestMapping("/effectList")
    public ResultObject effectList(@RequestBody HashMap<String, Object> map) {
        log.info("controller-请求参数：{}", map);
        return service.effectList(map);
    }


    @RequestMapping("/priority")
    public ResultObject priority(HttpServletRequest request) {
        Map<String, Object> params = ReqestParamUtil.getParams(request);
        return service.priority(params);
    }


}
